package com.kaguya.boke.blog.controller;


import com.kaguya.boke.blog.mapper.MaininfoMapper;
import com.kaguya.boke.blog.pojo.Maininfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.TimeZone;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 软件2018
 * @since 2021-11-21
 */
@RestController
@CrossOrigin
public class MaininfoController {
    @Autowired
    private MaininfoMapper maininfoMapper;
    @ResponseBody
    @RequestMapping("/getinfo")
    public List<Maininfo> getinfo(){
        List<Maininfo> maininfos = maininfoMapper.selectList(null);
        return maininfos;
    }
    @RequestMapping("/test")
    @ResponseBody
    public String test(){
        System.out.println("666");
        return "test";
    }

   @PostMapping("/sendinfo")
    public void sendinfo(@RequestBody Maininfo maininfo){

       Date d = new Date();
       maininfo.setCreatetime(d);
       int insert = maininfoMapper.insert(maininfo);
       System.out.println(insert);
   }
   @PostMapping("/isdelete")
    public void isDelete(@RequestBody Maininfo maininfo){
       int i = maininfoMapper.deleteById(maininfo);
       System.out.println(i);
   }
}

